CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

SET(CMAKE_BUILD_TYPE "Debug")
SET(TEST_WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data/)
ADD_DEFINITIONS(-DDATA_DIR="${TEST_WORKING_DIR}/")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-access-control")

INCLUDE_DIRECTORIES(${dbcommon_ROOT_DIR})
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/codegen/src)
INCLUDE_DIRECTORIES(/usr/libiconv/include)
INCLUDE_DIRECTORIES(${GLOG_INCLUDE_DIRS})
INCLUDE_DIRECTORIES($ENV{DEPENDENCY_INSTALL_PREFIX}/include)

LINK_DIRECTORIES(/usr/local/lib)
LINK_DIRECTORIES(/usr/libiconv/lib64)
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src)
LINK_DIRECTORIES($ENV{DEPENDENCY_INSTALL_PREFIX}/lib)

ADD_SUBDIRECTORY(unit)

IF(TEST_RUNNER)
    SEPARATE_ARGUMENTS(TEST_RUNNER_LIST UNIX_COMMAND ${TEST_RUNNER})
ENDIF(TEST_RUNNER)

ADD_CUSTOM_TARGET(unittest
    COMMAND ${TEST_RUNNER_LIST} ${CMAKE_CURRENT_BINARY_DIR}/unit/unit
    DEPENDS unit
    WORKING_DIRECTORY ${TEST_WORKING_DIR}
    COMMENT "Run Unit Test..."
)

ADD_CUSTOM_TARGET(punittest
    COMMAND ${TEST_RUNNER_LIST} ${CMAKE_CURRENT_BINARY_DIR}/unit/unit
    DEPENDS unit
    WORKING_DIRECTORY ${TEST_WORKING_DIR}
    COMMENT "Run Unit Test in parallel..."
)
